Chi-square and G-square tests of (unconditional) indepdence: Chi-square and G-square tests of (unconditional) indepdence
Description
Chi-square and G-square tests of (unconditional) indepdence.
Usage
cat.tests(x, y, logged = FALSE)
Value
A matrix with two rows. In each row the \(X^2\) or \(G^2\) test statistic, its p-value and the degrees of freedom are returned.
Arguments
x
A numerical vector or a factor variable with data. The data must be consecutive numbers.
y
A numerical vector or a factor variable with data. The data must be consecutive numbers.
logged
Should the p-values be returned (FALSE) or their logarithm (TRUE)?
Author
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
Details
The function calculates the test statistic of the \(X^2\) and the \(G^2\) tests of unconditional
independence between x and y. x and y need not be numerical vectors like in g2test. This
function is more close to the spirit of MASS' loglm()" function which calculates both statistics
using Poisson log-linear models (Tsagris, 2017).
References
Tsagris M. (2021). A new scalable Bayesian network learning algorithm with applications to economics.
Computational Economics, 57(1): 341--367.
Tsagris M. (2017). Conditional independence test for categorical data using Poisson log-linear model.
Journal of Data Science, 15(2): 347--356.